home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / Samples / Moofwars 1.02 / Tim's Libraries / Scaling.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-10  |  2.7 KB  |  76 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************
  2. Scaling.h
  3.  
  4. Scaling implements a standard 2D canvas to draw a set of TGraphics and tiles into.
  5. It also provides a set of globals that allow the sprite's location to be relative
  6. to a specific camera location.
  7.  
  8. Author: Timothy Carroll
  9. Apple Developer Technical Support
  10. timc@apple.com
  11.  
  12. Modification History: 
  13.  
  14. 8/15/96        TMC     Initial Release
  15.  
  16. Copyright © 1996 Apple Computer, Inc., All Rights Reserved
  17.  
  18. You may incorporate this sample code into your applications without
  19. restriction, though the sample code has been provided "AS IS" and the
  20. responsibility for its operation is 100% yours.  However, what you are
  21. not permitted to do is to redistribute the source as "DSC Sample Code"
  22. after having made changes. If you're going to re-distribute the source,
  23. we require that you make it clear in the source that the code was
  24. descended from Apple Sample Code, but that you've made changes.
  25.  
  26. *************************************************************************************/
  27.  
  28. #ifndef _SCALING_
  29. #define _SCALING_
  30.  
  31. #include <QuickDraw.h>
  32.  
  33. // We define all the world coordinate scaling information here, and also define functions
  34. // for choosing the drawing buffer and clipping to it.  The drawing buffer will be used by
  35. // TGraphic and TTile objects and any other class of offscreen blitters we make in the future.
  36.  
  37.  
  38. // WorldRect32 is a rectangle in 16.16 fixed point coordinates.  FixedPoint coordinates are
  39. // used for all coordinates in the game.  Anything in world coordinates should be converted
  40. // to screen coordinates before being drawn.
  41. // This structure defines a rectangle in 16.16 fixed point coordinates -- these are used as
  42. // the world coordinates for the game, they must be translated into screen coordinates
  43. // before drawing can take place.
  44.  
  45. struct WorldRect32
  46. {
  47.     SInt32 top;
  48.     SInt32 left;
  49.     SInt32 bottom;
  50.     SInt32 right;
  51. };
  52.  
  53. // For the most part, we define a number of globals that can be read freely, but 
  54. // the functions should be called whenever one of these globals needs to be updated.
  55. // This is because more than one global might need to be set, and the functions do the
  56. // right thing.
  57.  
  58.  
  59.  
  60. extern SInt32             gWorldCoordX;
  61. extern SInt32             gWorldCoordY;
  62. extern Rect               gClipRect;
  63. extern SInt32             gClipCenterX;
  64. extern SInt32             gClipCenterY;
  65.  
  66. extern PixMapHandle     gDestPixMap;
  67. extern PixMapHandle     gBackPixMap;
  68. extern unsigned char    *gDestBaseAddr;
  69. extern unsigned char    *gBackBaseAddr;
  70. extern UInt32            gRowBytes;
  71.     
  72. extern void SetDestinationBuffer(PixMapHandle inDestPixMap, PixMapHandle inBackPixMap);
  73. extern void SetBufferClip(Rect *inClipRect);
  74. extern void SetWorldOrigin (SInt32 x, SInt32 y);
  75.  
  76. #endif // _SCALING_